A transcoder is an effective tool for dynamically encoding a coded stream into an output stream having a different bit rate, especially in a network environment and in diverse video services. Without completely decoding an input stream into its uncompressed format, the transcoder is capable of re-encoding the input stream into a compressed stream with a different bit rate.
Compared to a conventional re-encoder or closed loop architecture, open loop architecture has characteristics of low computational complexity and fast speed. In the open loop architecture, an input stream is partially decoded to generate Discrete Cosine Transform (DCT) coefficients. These DCT coefficients are subsequently re-quantized using a new quantization parameter (Qp) related to an output bit rate.
The calculation of the new Qp will affect the performance of the output stream. During the re-quantization of macroblocks (MBs), drift errors are easily generated due to data loss attributed to the MBs that are repeatedly referenced by the MBs of succeeding frames. For instance, some prior patents only consider the ratio of a new bit rate to an original bit rate, thereby easily resulting in drift errors.
Referring to FIGS. 1 and 2, in U.S. Pat. No. 6,700,935 B2, entitled “Stream based bitrate transcoder for MPEG coded video”, there is disclosed a method comprising the following steps. First, information comprising motion vectors and picture/macroblock types for all frames in a Group of Pictures (GOP) is extracted from a bit stream. Next, a number of bits for encoding DCT coefficients by Variable Length Coding (VLC) decoding is calculated, and the bit stream is decoded and transformed into a DCT bit stream accordingly. After a bit rate difference is determined, some DCT coefficients are dropped based upon the information in order to achieve the bit rate difference in the DCT bit stream, wherein the bit rate difference (D) is distributed among lntra-MB and Inter-MB groups based upon the following equations:D=D_intra—mb+D_inter—mb (D_intra—mb)/(D_inter—mb)=(A′p+A′b)/(Ai+Ap+Ab)
where A is the average bit count, A′ is the new average bit count, i represents anchor frames, p represents predicted frames, and b represents bidirectional frames.
Reference links of each MB can be calculated according to associated motion vectors and the MB type. The number of reduction bits of each MB can be determined according to priority given to the reference links. FIG. 2 illustrates a search scope and a best matching macroblock for macroblock (K) in frame (i+1).
As shown in FIG. 2, based on the motion vector and the position of the current macroblock (K), the reference links may be counted equally among macroblocks (A), (B), (C), and (D), or proportionally to the areas in the macroblocks (A), (B), (C) and (D) respectively covered by the best matching macroblock. In the case where the reference links are counted equally among the macroblocks (A), (B), (C) and (D), each reference count is incremented by 1. On the other hand, in the case where the reference links are counted proportionally to the areas in the macroblocks (A), (B), (C) and (D) respectively covered by the best matching macroblock, the reference link counts are incremented by fractions associated with the areas in the macroblocks (A), (B), (C) and (D) respectively covered by the best matching macroblock. In the latter case, the fraction numbers have an order of C>A=D>B. After the calculation of the reference links is finished, the number of reduction bits may again be proportionally distributed.
In the aforementioned U.S. patent, DCT coefficients that can be dropped for each MB are calculated according to the picture/macroblock type and the motion reference numbers. However, due to accumulation of errors, the dropped coefficients will lead to continuous picture quality loss. To remedy this situation, this patent teaches pre-scanning of the whole GOP so as to obtain information, such as the picture/macroblock type, coding complexity, and motion vectors. By utilizing these data, motion reference numbers can be calculated according to the importance of each MB so as to determine the number of bits to be dropped and to reduce drift errors.
Nevertheless, the calculation of motion reference numbers requires pre-scanning of the whole GOP to retrieve associated motion vectors and obtain the positions of the referenced MBs. The process as such increases computational complexity, and is not suitable for all situations, such as environments with time or resource constraints.